<?php

namespace common\models;

use Yii;
/**
 * This is the model class for table "article_image".
 *
 * @property int $id
 * @property int $aid
 * @property int $image_id
 *
 * @property Article $a
 * @property Image $image
 */
class ArticleImage extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'article_image';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['aid', 'image_id'], 'integer'],
            [
                ['aid'],
                'exist',
                'skipOnError'     => true,
                'targetClass'     => Article::className(),
                'targetAttribute' => ['aid' => 'id']
            ],
            [
                ['image_id'],
                'exist',
                'skipOnError'     => true,
                'targetClass'     => Image::className(),
                'targetAttribute' => ['image_id' => 'id']
            ],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id'       => 'ID',
            'aid'      => 'Aid',
            'image_id' => 'Image ID',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getA()
    {
        return $this->hasOne(Article::className(), ['id' => 'aid']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getImage()
    {
        return $this->hasOne(Image::className(), ['id' => 'image_id']);
    }
}
